package de.mhu.mandalaui;

import de.mhu.mandalaui.actions.Action;
import de.mhu.mandalaui.attributes.Attribute;
import de.mhu.mandalaui.attributes.BooleanAttribute;
import de.mhu.mandalaui.attributes.MultiAttribute;
import de.mhu.mandalaui.bind.Element;

public class StyleFilter implements Styleable {

	public enum FILTER {CLASS,STYLE,CLICK,VALUE,VISIBLE,CSS,WITH,EMPHASIS,SIZE,ID, BASE};
	private FILTER[] disabled;
	private FILTER[] enabled;
	private Styleable style;
	private String myClass;
	private String myStyle;
	private Action myClickAction;
	private Element myBindValue;
	private String myId;
	private MultiAttribute myCss;
	private Attribute myWith;
	private EMPHASIS myEmphasis;
	private String myBase;
	private SIZE mySize;
	private BooleanAttribute myBindVisible;

	public StyleFilter(Styleable style, FILTER ... enabled) {
		this.style = style;
		this.enabled = enabled;
	}
	
	public void setStyleClass(String classes) {
	}

	public void setExtraStyle(String style) {
	}

	public String getStyleClass() {
		if (is(FILTER.CLASS))
			return style.getStyleClass();
		return getMyClass();
	}

	public String getExtraStyle() {
		if (is(FILTER.STYLE))
			return style.getExtraStyle();
		else
			return getMyStyle();
	}

	public Action getClickAction() {
		if (is(FILTER.CLICK))
			return style.getClickAction();
		return getMyClickAction();
	}

	public Element getBindValue() {
		if (is(FILTER.VALUE))
			return style.getBindValue();
		return getMyBindValue();
	}

	public BooleanAttribute getBindVisible() {
		if (is(FILTER.VISIBLE))
			return style.getBindVisible();
		return getMyBindVisible();
	}

	public String getId() {
		if (is(FILTER.ID))
			return style.getId();
		return getMyId();
	}

	public MultiAttribute getBindCss() {
		if (is(FILTER.CSS))
			return style.getBindCss();
		return getMyCss();
	}

	public Attribute getBindWith() {
		if (is(FILTER.WITH))
			return style.getBindWith();
		return getMyWith();
	}

	public EMPHASIS getEmphasisStyle() {
		if (is(FILTER.EMPHASIS))
			return style.getEmphasisStyle();
		return getMyEmphasis();
	}

	public String getStyleBase() {
		if (is(FILTER.BASE))
			return style.getStyleBase();
		return getMyBase();
	}

	public SIZE getSizeStyle() {
		if (is(FILTER.SIZE))
			return style.getSizeStyle();
		return getMySize();
	}

	private boolean is(FILTER is) {
		if (disabled != null) {
			for (FILTER f : disabled)
				if (f == is) return false;
		}
		if (enabled == null) return true;
		for (FILTER f : enabled)
			if (f == is) return true;
		return false;
	}

	public Styleable getStyle() {
		return style;
	}

	public void setStyle(Styleable style) {
		this.style = style;
	}

	public FILTER[] getEnabled() {
		return enabled;
	}

	public void setEnabled(FILTER[] enabled) {
		this.enabled = enabled;
	}

	public String getMyClass() {
		return myClass;
	}

	public void setMyClass(String myClass) {
		this.myClass = myClass;
	}

	public String getMyStyle() {
		return myStyle;
	}

	public void setMyStyle(String myStyle) {
		this.myStyle = myStyle;
	}

	public Action getMyClickAction() {
		return myClickAction;
	}

	public void setMyClickAction(Action myClickAction) {
		this.myClickAction = myClickAction;
	}

	public Element getMyBindValue() {
		return myBindValue;
	}

	public void setMyBindValue(Element myBindValue) {
		this.myBindValue = myBindValue;
	}

	public String getMyId() {
		return myId;
	}

	public void setMyId(String myId) {
		this.myId = myId;
	}

	public MultiAttribute getMyCss() {
		return myCss;
	}

	public void setMyCss(MultiAttribute myCss) {
		this.myCss = myCss;
	}

	public Attribute getMyWith() {
		return myWith;
	}

	public void setMyWith(Attribute myWith) {
		this.myWith = myWith;
	}

	public EMPHASIS getMyEmphasis() {
		return myEmphasis;
	}

	public void setMyEmphasis(EMPHASIS myEmphasis) {
		this.myEmphasis = myEmphasis;
	}

	public String getMyBase() {
		return myBase;
	}

	public void setMyBase(String myBase) {
		this.myBase = myBase;
	}

	public SIZE getMySize() {
		return mySize;
	}

	public void setMySize(SIZE mySize) {
		this.mySize = mySize;
	}

	public BooleanAttribute getMyBindVisible() {
		return myBindVisible;
	}

	public void setMyBindVisible(BooleanAttribute myBindVisible) {
		this.myBindVisible = myBindVisible;
	}

	public FILTER[] getDisabled() {
		return disabled;
	}

	public void setDisabled(FILTER[] disabled) {
		this.disabled = disabled;
	}
	
}
